<?php

namespace IDock\Insurance\LIHI\Response;

use IDock\Http\Response;
use IDock\Insurance\LIHI\Response\AllLIHIResponse;
use IDock\Printer\ProposalStatusPrinter;

class ProposalStatusResponse extends AllLIHIResponse
{

    /**
     * @var ProposalStatusPrinter $printer
     */
    public $printer = ProposalStatusPrinter::class;

    public function printerInit(): Response
    {
        $body = $this->getBody()['result'] ?? [];

        $status1 = $status2 = '9';

        //核保通过
        if (in_array($status1, ['1', '3', '4']) and in_array($status2, ['1', '3', '4'])) {
            $this->printer->statusCode = 'U1';
        }

        //核保退回
        if (in_array($status1, ['2']) or in_array($status2, ['2'])) {
            $this->printer->statusCode = 'U2';
        }

        //人工核保
        if ($status1 == '9' or $status2 == '9') {
            $this->printer->statusCode = 'U3';
        }

//        //核保失败
//        if (in_array($status1, ['5', '6']) or in_array($status2, ['5', '6'])) {
//            $this->printer->statusCode = 'U4';
//        }
//
//        //已出保单
//        if ($status1 == '10' or $status2 == '10') {
//            $this->printer->statusCode = 'U5';
//        }

        return $this;
    }
}
